package com.mapper;

import com.entity.Employee;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.vo.EmployeeVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 *  员工Mapper 接口
 * </p>
 *
 * @author aiou
 * @since 2025-06-12
 */
@Mapper
public interface EmployeeMapper{

    //用户管理：分页和下拉框查询
    List<EmployeeVO> list(@Param("form") Employee employee);

    //用户管理：设置状态
    int setStatus(Integer status, Integer id);

    //用户管理：重置密码
    int resetPassword(String password, Integer id);

    //用户管理：添加功能保存
    boolean save(Employee employee);

    //用户管理：编辑员工-Id查询
    @Select("select * from employee where employee_id = #{id}")
    Employee seletcById(Integer id);

    //用户管理：编辑员工
    @Update("update employee set employee_name = #{employeeName},department_id = #{departmentId},sex = #{sex},phone = #{phone},email = #{email},university = #{university},major = #{major},education = #{education},address = #{address},remark = #{remark},password = #{password},status = #{status} " +
            "where employee_id = #{employeeId}")
    boolean updateById(Employee employee);

    //用户管理：删除员工
    @Delete("delete from employee where employee_id = #{id}")
    boolean deleteById(Integer id);

    //部门管理：查询所有员工
    @Select("select * from employee")
    List<Employee> listAllEmployee();

    //登录：查询手机号
    @Select("select * from employee where phone = #{phone}")
    Employee selectByPhone(String phone);

    //角色权限：根据部门Id查询所有员工
    @Select("select * from employee where department_id = #{departmentId}")
    List<Employee> selectByDepartmentId(Integer departmentId);
}
